﻿/*
Поменял Евгений Веприков 19 октября 2006 года
Данные для распечатки ценников и стелажных карточек
вид XML 
<r>
<i v="345"/>
<i v="944"/>
<i v="549"/>
</r>
*/
CREATE procedure [dbo].[Reports_GetSZData]
@xml text
as
begin
declare @idoc int
BEGIN TRY
EXEC sp_xml_preparedocument @idoc OUTPUT, @xml
SELECT CA.Documents.DocNumber, vwGoodsDetailed.FullName, 
vwGoodsDetailed.ManufacturerName, CD.Parties.RestQntty, CA.Documents.DocDate, 
CD.Parties.BarCode, CD.InputLines.CertificateNumber, CD.InputLines.BatchNumber, 
CD.Parties.Id, CD.Parties.RetailPrice, CD.InputLines.CertificateDate,
CA.Contragents.ShortName as ContragentName, 
CA.Documents.ContragentDocDate, CA.Documents.ContragentDocNumber
FROM CD.Parties INNER JOIN
vwGoodsDetailed ON CD.Parties.GoodsId = vwGoodsDetailed.Id INNER JOIN
CA.Documents ON CD.Parties.DocId = CA.Documents.Id INNER JOIN
CD.InputLines ON CD.Parties.InputLineId = CD.InputLines.Id INNER JOIN
CA.Contragents ON CA.Documents.ContragentId = CA.Contragents.Id 
INNER JOIN (SELECT    v FROM OPENXML (@idoc, '/r/i',1) WITH (v  int))as xmlParties
ON xmlParties.v = CD.Parties.Id
order by vwGoodsDetailed.FullName
END TRY
BEGIN CATCH

END CATCH
if(@idoc is not null)
begin
exec sp_xml_removedocument @idoc
end
end




